package caom.wangs.java8.lamda;

public class LamdaDemo1 {
    public static void main(String[] args) {
        //参数声明
        create((a, b) -> a + b);
        create((String a, String b) -> a + b);

        //实现逻辑
        //单行语句块
        create((a, b) -> a + b);
        //单行语句块
        create((a, b) -> {
            System.out.println("多行语句块必须有结果");
            return a + b;
        });

        //静态方法引用
        create(LamdaDemo1::build);

        //非静态方法引用
        create(new LamdaDemo1()::build2);

        // 参数方法引用
        create(String::concat);
        //js代码中常见 ： 方法引用

    }

    public static void create(MyInterface myInterface) {
        myInterface.build("wt", "hollow man");
    }

    public static String build(String name, String msg) {
        return name + msg;
    }

    public String build2(String name, String msg) {
        return name + msg;
    }

    @FunctionalInterface
    public interface MyInterface {
        String build(String name, String msg);
    }
}
